home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / NervousTextBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  210 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/19/98    LAB    Moved to GroupAWTMultimedia folder.
  8.  
  9. /**
  10.  * BeanInfo for NervousText.
  11.  *
  12.  */
  13.  
  14. public class NervousTextBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a NervousTextBeanInfo object.
  18.      */
  19.     public NervousTextBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTMultimedia"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.         bd.setWinHelp("0x12341");
  48.  
  49.         return (BeanDescriptor) bd;
  50.     }
  51.  
  52.     /**
  53.      * Gets an image that may be used to visually represent this bean
  54.      * (in the toolbar, on a form, etc).
  55.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  56.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  57.      * @return an image for this bean, always color even if requested monochrome
  58.      * @see BeanInfo#ICON_MONO_16x16
  59.      * @see BeanInfo#ICON_COLOR_16x16
  60.      * @see BeanInfo#ICON_MONO_32x32
  61.      * @see BeanInfo#ICON_COLOR_32x32
  62.      */
  63.     public java.awt.Image getIcon(int iconKind) {
  64.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  65.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  66.             java.awt.Image img = loadImage("NervousTextC16.gif");
  67.             return img;
  68.         }
  69.  
  70.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  71.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  72.             java.awt.Image img = loadImage("NervousTextC32.gif");
  73.             return img;
  74.         }
  75.  
  76.         return null;
  77.     }
  78.  
  79.     /**
  80.      * Gets an array of descriptions of the methods used for "connections" by
  81.      * Visual CafΘ's Interaction Wizard.
  82.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  83.      * @return method descriptions for this bean
  84.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  85.      */
  86.     public MethodDescriptor[] getMethodDescriptors() {
  87.         Class[] args;
  88.         ConnectionDescriptor connection;
  89.         java.util.Vector connections;
  90.         java.util.Vector md = new java.util.Vector();
  91.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  92.  
  93.         try{
  94.             args = null;
  95.             MethodDescriptor isPaused = new MethodDescriptor(beanClass.getMethod("isPaused", args));
  96.  
  97.             connections = new java.util.Vector();
  98.             connection = new ConnectionDescriptor("output", "boolean", "",
  99.                                     "%name%.isPaused()",
  100.                                     conn.getString("isPaused"));
  101.             connections.addElement(connection);
  102.  
  103.             connection = new ConnectionDescriptor("output", "boolean", "",
  104.                                     "!%name%.isPaused()",
  105.                                     conn.getString("isRunning"));
  106.             connections.addElement(connection);
  107.  
  108.             isPaused.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  109.             md.addElement(isPaused);
  110.         } catch (Exception e) { throw new Error("isPaused:: " + e.toString()); }
  111.  
  112.         try{
  113.             args = new Class[1];
  114.             args[0] = java.lang.String.class ;
  115.             MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
  116.  
  117.             connections = new java.util.Vector();
  118.             connection = new ConnectionDescriptor("input", "String", "",
  119.                                     "%name%.setText(%arg%);",
  120.                                     conn.getString("setText"));
  121.             connections.addElement(connection);
  122.  
  123.             setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  124.             md.addElement(setText);
  125.         } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
  126.  
  127.         try{
  128.             args = null;
  129.             MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
  130.  
  131.             connections = new java.util.Vector();
  132.             connection = new ConnectionDescriptor("output", "String", "",
  133.                                     "%name%.getText()",
  134.                                     conn.getString("getText"));
  135.             connections.addElement(connection);
  136.  
  137.             getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  138.             md.addElement(getText);
  139.         } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
  140.  
  141.         try{
  142.             args = new Class[1];
  143.             args[0] = java.lang.Boolean.TYPE ;
  144.             MethodDescriptor setPaused = new MethodDescriptor(beanClass.getMethod("setPaused", args));
  145.  
  146.             connections = new java.util.Vector();
  147.             connection = new ConnectionDescriptor("input", "void", "",
  148.                                     "%name%.setPaused(true);",
  149.                                     conn.getString("setPaused"));
  150.             connections.addElement(connection);
  151.  
  152.             connection = new ConnectionDescriptor("input", "void", "",
  153.                                     "%name%.setPaused(false);",
  154.                                     conn.getString("setPausedResume"));
  155.             connections.addElement(connection);
  156.  
  157.             connection = new ConnectionDescriptor("input", "boolean", "",
  158.                                     "%name%.setPaused(%arg%);",
  159.                                     conn.getString("setPausedCondition"));
  160.             connections.addElement(connection);
  161.  
  162.             connection = new ConnectionDescriptor("input", "void", "",
  163.                                     "%name%.setPaused(!%name%.isPaused());",
  164.                                     conn.getString("setPausedToggle"));
  165.             connections.addElement(connection);
  166.  
  167.             setPaused.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  168.             md.addElement(setPaused);
  169.         } catch (Exception e) { throw new Error("setPaused:: " + e.toString()); }
  170.  
  171.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  172.         md.copyInto(rv);
  173.  
  174.         return rv;
  175.     }
  176.  
  177.     /**
  178.      * Returns descriptions of this bean's properties.
  179.      */
  180.     public PropertyDescriptor[] getPropertyDescriptors() {
  181.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  182.  
  183.         try{
  184.         PropertyDescriptor defProperty = new PropertyDescriptor("text", beanClass);
  185.         defProperty.setBound(true);
  186.         defProperty.setConstrained(true);
  187.         defProperty.setDisplayName(prop.getString("text"));
  188.  
  189.         PropertyDescriptor paused = new PropertyDescriptor("paused", beanClass);
  190.         paused.setBound(true);
  191.         paused.setConstrained(true);
  192.         paused.setDisplayName(prop.getString("paused"));
  193.  
  194.         PropertyDescriptor[] rv = {
  195.             defProperty,
  196.             paused};
  197.         return rv;
  198.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  199.     }
  200.  
  201.     /**
  202.      * Returns the index of the property expected to be changed most often by the designer.
  203.      */
  204.     public int getDefaultPropertyIndex() {
  205.         return 0;    //  the index for our default property is always 0
  206.     }
  207.  
  208.     private final static Class beanClass = NervousText.class;
  209.  
  210.     }    //  end of class NervousTextBeanInfo